﻿using System;
using System.Collections.Generic;
using System.Text;
using Mighty.Common;

namespace Mighty.Brain
{
    public class YJBrain : BasicBrain
    {
        public override Betting BettingTicEvent()
        {
            Betting betting = new Betting();

            betting.isPass = true;

            // 각 무늬의 개수를 센다
            int heart = 0;
            int clover = 0;
            int spade = 0;
            int diamond = 0;
            for (int i = 0; i < 10; i++)
            {
                HandedCard card = gameInfo.myCards[i];
                if (card.shape == Shape.Clover) clover++;
                else if (card.shape == Shape.Heart) heart++;
                else if (card.shape == Shape.Spade) spade++;
                else if (card.shape == Shape.Diamond) diamond++;
            }

            // 가장 많은 무늬를 찾아 낸다
            Giruda selectedShape = Giruda.Heart;
            int selectedCount = heart;

            if (clover > selectedCount)
            {
                selectedShape = Giruda.Clover;
                selectedCount = clover;
            }
            if (spade > selectedCount)
            {
                selectedShape = Giruda.Spade;
                selectedCount = spade;
            }
            if (diamond > selectedCount)
            {
                selectedShape = Giruda.Diamond;
                selectedCount = diamond;
            }
            betting.giruda = selectedShape;

            // 14이하로 베팅한다
            if (gameInfo.betting.limit > 0)
            {
                Betting previousBetting = (Betting)gameInfo.bettingHistory[gameInfo.bettingHistory.Count - 1];
                if (previousBetting.limit < 15)
                {
                    betting.isPass = false;
                    betting.limit = previousBetting.limit + 1;
                }

            }
            else
            {
                betting.isPass = false;
                betting.limit = 13;
            }

            
            return betting;
 
        }

    }
}
